#include "demo1.h"
#include <i_component_factory.h>
#include <i_log.h>
#include <sstream>

CDemo1::CDemo1()
{
	_AddDependence(m_command_ptr);
}

CDemo1::~CDemo1()
{

}

int CDemo1::_OnStart()
{
	m_command_ptr->GetCommandSignal("demo1").connect(this, [](const CCommandInfoPtr& cmd) -> void {
		std::stringstream opt;
		for (const auto& it : cmd->options)
			opt << it.first << " : " << it.second << "\n";

		std::stringstream param;
		for (const auto& p : cmd->params)
			param << p << "\n";
		
		SPDLOG_INFO("options:\n{}params\n{}", opt.str(), param.str());
	});

	return CComponent::_OnStart();
}

DEFINE_COMPONENT(COM_DEF<CDemo1, IDemo1>);